package maher;

import java.io.*;
import java.net.*;
import java.util.*;
import java.util.regex.*;

public class GetMac {
	public static void main(String[] args) throws IOException {
		String address = new GetMac().getMacAddress();
		System.out.println(address);
	}

	public String getMacAddress() throws IOException {
		String macAddress = null;
		String command = "ipconfig /all";
		Process pid = Runtime.getRuntime().exec(command);
		BufferedReader in = new BufferedReader(new InputStreamReader(pid.getInputStream()));
		while (true) {
			String line = in.readLine();
			if (line == null)
				break;
			Pattern p = Pattern.compile(".*Physical Address.*: (.*)");
			Matcher m = p.matcher(line);
			if (m.matches()) {
				macAddress = m.group(1);
				break;
			}
		}
		in.close();
		return macAddress;
	}
}